Copyright(C) 1994,1995,1996,1997 Terumasa KODAKA , Takeshi KONO
■Keyboard interface
Target            Normal, high resolution, PC-98LT・HA
Chip              8251A (equivalent)
Explanation     o In the PC-9800 series, keyboard key input information is sent to the main unit as a serial signal (fixed at 19200bps).
                  When the keyboard I/F 8251A (equivalent) receives key input information, it generates an INT 09h interrupt and notifies
                  software (BIOS, etc.) of the key input.
                o Even with models that have an integrated keyboard and main body, such as 98NOTE and PC-98LT/HA, the keyboard and
                  keyboard I/F communicate serially, just like desktop machines.
                u With the 98NOTE series, it is possible to connect a full keyboard to the numeric keypad connector.
                o In the PC-9800 series, the 8251 TXD signal line is connected to RST# (keyboard connector pin 1) and was originally used
                  to reset the keyboard, but the new keyboard uses this to send commands. It started to be done.
                o Models with new keyboards can send commands to the keyboard. You can obtain the lock status of the [CAPS], [Kana], and
                  [NUM] keys, control the lock status, and change the key repeat interval.
                o The following keyboards are valid for the PC-9800 series.
                  ----------------------------+---------------------------------------------
                   Old keyboard               |
                  +---------------------------+---------------------------------------------
                  | PC-98LT                   | [BS],[ROLL UP],[ROLL DOWN],[DEL],[HELP],[COPY]
                  |                           | There is no key, but you can use the following operation instead.
                  |                           | [BS],[DEL] =[DEL BS]
                  |                           | [HELP] =[CTRL]+[SHIFT]+[H]
                  |                           | [ROLL UP] =[CTRL]+[SHIFT]+[↑]
                  |                           | [ROLL DOWN]=[CTRL]+[SHIFT]+[↓]
                  |                           | [COPY] =[CTRL]+[SHIFT]+[P]
                  +---------------------------+---------------------------------------------
                  | High resolution           | PC-98XA・XL・XL^2
                  +---------------------------+---------------------------------------------
                  | No NFER                   | PC-9801 first generation・E・F・M
                  +---------------------------+---------------------------------------------
                  | Other                     | Other than PC-9801 first generation/E/F/M
                 -+---------------------------+---------------------------------------------
                   New keyboard               |
                  +---------------------------+---------------------------------------------
                  | 98NOTE                    | 98NOTE series
                  +---------------------------+---------------------------------------------
                  | PC-9801-98                | Rakuraku Keyboard
                  +---------------------------+---------------------------------------------
                  | PC-9801-106               | 98 standard keyboard (Windows key, no application key)
                  +---------------------------+---------------------------------------------
                  | PC-9801-114               | PC-PTOS keyboard
                  +---------------------------+---------------------------------------------
                  | PC-9801-115               | Bungo DP Keyboard
                  +---------------------------+---------------------------------------------
                  | PC-9801-116               | 106 keyboard
                  +---------------------------+---------------------------------------------
                  | PC-9801-119               | 98 standard keyboard (with Windows key and application key)
                  +---------------------------+---------------------------------------------
                  | Others                    | PC-9801-106, PC-9801T-03 equivalent
                 -+---------------------------+---------------------------------------------
Related           I/O 0000h bit 1
                  INT 18h - Function 00~09h
                  INT 09h (external interrupt)
                  0000:0502~053Ah
I/O               0041h
Name              Keyboard interface
Function
                  [READ] Read received data
                  bit 7~0: Make/break code, status
                            00~7Fh=Make code
                            80~FFh=break code
                            FAh=ACK
                            FCh=NACK
                  [WRITE] Write transmit data
                  bit 7~0: Down command
                            ----------------+---------------------------------------------------
                            Command         | Content
                            ----------------+---------------------------------------------------
                            95h             | Extended key settings■[PC-9801-98・119](Undocumented)
                                            | * Output parameters in 2nd byte
                                            |   bit 7~0:
                                            |     00h=normal
                                            |     03h=Windows key, application key enabled
                                            |   ■[PC-9801-119]
                            ----------------+---------------------------------------------------
                            96h             | Mode identification■[PC-9801-98](Undocumented)
                                            | * A0h,86h is returned in automatic conversion mode
                                            | * A0h,85h is returned in normal mode
                            ----------------+---------------------------------------------------
                            99h             | Undocumented
                                            | * FBh is returned
                            ----------------+---------------------------------------------------
                            9Ch             | Keyboard repeat speed setting (Undocumented)
                                            | * Output parameters in 2nd byte
                                            | bit 7: Unused
                                            | bit 6,5: Delay
                                            |          11b=1000ms
                                            |          10b=500ms
                                            |          01b=500ms (default)
                                            |          00b=250ms
                                            | bit 4~0: Repeat speed
                                            |           11111b=lowest speed
                                            |           00001b= Maximum speed (default)
                            ----------------+---------------------------------------------------
                            9Dh             | Unknown■[PC-9801NS/T](Undocumented)
                                            | * Output parameters in 2nd byte
                                            |   00h=Unknown
                                            |   01h=Unknown
                            ----------------+---------------------------------------------------
                            9Dh             | Keyboard LED reading (Undocumented)
                                            | * Send 60h to 2nd byte
                                            | * LED status is sent in the following format
                                            |   bit 7~4: Unused
                                            |   bit 3: [Kana] LED
                                            |   bit 2: [CAPS] LED
                                            |   bit 0: [NUM] LED
                                            |     1=ON
                                            |     0=OFF
                            ----------------+---------------------------------------------------
                            9Dh             | Keyboard LED settings
                                            | * Output parameters in 2nd byte
                                            |   bit 7~4: always 0111b
                                            |   bit 3: [Kana] LED
                                            |   bit 2: [CAPS] LED
                                            |   bit 0: [NUM] LED (Undocumented)
                                            |     1=ON
                                            |     0=OFF
                            ----------------+---------------------------------------------------
                            9Eh             | Undocumented
                            ----------------+---------------------------------------------------
                            9Fh             | Keyboard type identification
                                            | * New keyboard returns A0h,80h
                            ----------------+---------------------------------------------------
Description     o Get the make/break code from the keyboard.
                o Issue a down command to the keyboard.
Related           I/O 0041h
I/O               0043h
Name              Keyboard interface
Function
                  [READ] ■Meaning of bits when reading status
                  bit 7: DSR input terminal
                         1=HIGH level
                         0=LOW level
                         * Indicates the status of keyboard connector pin 6. (Undocumented)
                  bit 6: SYNC/BRK
                         1=Break detection
                         0=None
                         * Does not occur as long as a regular handshake with the keyboard is performed.
                  bit 5: Framing error (FE) detection
                         1=Yes
                         0=None
                  bit 4: Overrun error (OE) detection
                         1=Yes
                         0=None
                         * Does not occur as long as a regular handshake with the keyboard is performed.
                  bit 3: Parity error (PE) detection
                         1=Yes
                         0=None
                  bit 2: TxEMP (end of transmission)
                  bit 1: RxRDY (data reception)
                  bit 0: TxRDY (transmission possible)
                  [WRITE] ■Meaning of bits when writing command word
                  bit 7: Enterhunt phase
                         * Keyboard I/F is not used because it is asynchronous communication. Set to 0.
                  bit 6: 8251A reset
                         1=Do
                         0=No
                  bit 5: RTS terminal control
                         1=RDY# signal line is always inactive
                         0=RDY# signal line follows the state of RxRDY
                         * The keyboard I/F controls the operation of the RDY# signal line (keyboard connector pin 3).
                  bit 4: Clear error flag
                         1=Clear FE, OE, PE of 8251A
                         0=Do not clear error
                  bit 3: TxDATA break transmission
                         1=Set RST# signal line to LOW level
                         0=RST# signal line to HIGH level
                         * The keyboard I/F controls the operation of the RST# signal line (keyboard connector pin 1).
                           When the RST# signal line is set to LOW level for a period of 13μs or more, the CPU in the keyboard is reset.
                  bit 2: Receive permission
                         1=Receive data from keyboard
                         0=Do not receive data from keyboard
                  bit 1: DTR signal
                         1=RTY# signal to HIGH level
                         0=RTY# signal to LOW level
                         * The keyboard I/F controls the operation of the RTY# signal line (keyboard connector pin 5). Usually HIGH. When LOW, requests the keyboard to resend data.
                  bit 0: Send permission
                         1=Send data from RST# signal line
                         0=Do not send data from RST# signal line
                         * The keyboard I/F uses the RST# signal line when issuing down commands to the keyboard. Set to 1 when sending a command.
                  [WRITE] ■Meaning of bits during mode write
                  bit 7,6: ST2,ST1 (number of transmission stop bits)
                           Set 01b (1 bit)
                  bit 5,4: P1,P0 (parity generation/check)
                           Set 01b (odd parity)
                  bit 3,2: L1,L0 (character length)
                           Set 11b (8 bit)
                  bit 1,0: B1,B0 (baud rate)
                           Set 10b (16x clock)
Description     o Sets the mode of the 8251 equivalent used for the keyboard interface.
Related           I/O 0043h